<?php
require "require/connectdb.php";
//require "require/pagingfunction.php";
if(isset($_GET['check'])&&$_GET['check']==1){
	$thang=$_GET["thang"];
	$sql="select DISTINCT EXTRACT(DAY from date_complete) as daycc from detail_order where EXTRACT(MONTH from date_complete)='$thang'";
	$query=mysql_query($sql);
	echo "&nbsp;Ngày: <select id='chon_ngay'>";
	echo "<option value=0>Tất cả</option>";
	while($data=mysql_fetch_assoc($query)){
		echo "<option value='$data[daycc]'>$data[daycc]</option>";	
	}
	echo "</select>";
}else if(isset($_GET['check'])&&$_GET['check']==2){
	$thang=$_GET['thang'];
	$ngay=$_GET['ngay'];
	$nam=$_GET['nam'];
	$ban=$_GET['ban'];	
	$total=0;
	
	/*$lines_limit=5;
	$lines_total=lines_total1('detail_order',$ngay,$thang,$nam,$ban);
	$links_limit=1;
	$links_total=links_total($lines_total,$lines_limit);*/
	if($ngay==0){
		$sql="select * from detail_order,menu where EXTRACT(MONTH from date_complete)='$thang' and EXTRACT(YEAR from date_complete)='$nam' and table_id='$ban' and detail_order.menu_name=menu.name";	
	}else{
		$sql="select * from detail_order,menu where EXTRACT(DAY from date_complete)='$ngay' and EXTRACT(MONTH from date_complete)='$thang' and EXTRACT(YEAR from date_complete)='$nam' and table_id='$ban' and detail_order.menu_name=menu.name";
	}
	//$query=paging_query($sql,$lines_limit);
	$query=mysql_query($sql);
	echo "<table id='tablemenu'>";
	echo "<tr><th>Tên món ăn</th><th>Ngày</th><th>Giá</th></tr>";
	while($data=mysql_fetch_assoc($query)){
		$price=number_format($data['price'],0,',','.');
		$total=$total+$data['price'];
		echo "<tr>";
		echo "<td>$data[menu_name]</td><td>$data[date_order]</td><td>$price</td>";
		echo "</tr>";
	}
	echo "</table>";
	$total=number_format($total,0,',','.');
	echo "<div id='tongcong'><span id='tc1'>Tổng cộng: </span><span id='tc2'>$total</span></div>";
	
	/*echo "<div id='paging'>";
	paging_links($links_total,$links_limit);
	paging_list($links_total);
	echo "</div>";*/
}
?>